import 'package:fish_redux/fish_redux.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

import '../admin_user_list_page/admin_user_item_component/state.dart';

class AdminUserListState implements Cloneable<AdminUserListState> {
  RefreshController refreshController;
  List<AdminUserItemState> list;
  int total;
  String query;
  int page;
  final int pageSize = 20;

  AdminUserListState({
    this.refreshController,
    this.list,
    this.total = 0,
    this.page = 0,
    this.query = '',
  });

  @override
  AdminUserListState clone() {
    return AdminUserListState(
      refreshController: refreshController,
      list: list,
      total: total,
      page: page,
      query: query,
    );
  }

  bool get hasNextPage => (list?.length ?? 0) < total;
  bool get noData =>
      refreshController.footerStatus == LoadStatus.noMore && total == 0;
}

AdminUserListState initState(Map<String, dynamic> args) {
  return AdminUserListState(
    refreshController: RefreshController(
      initialRefresh: true,
    ),
    list: [],
    total: 0,
    page: 0,
    query: '',
  );
}
